<?php

/**
 * 
 * Deposer une annonce
 * @author Redouane
 *
 */
class SendAdsToFriendForm extends sfForm{
    public function configure(){
            
            $this->widgetSchema['sender'] = new sfWidgetFormInput();
            $this->widgetSchema['receiver'] = new sfWidgetFormInput();
            $this->widgetSchema['message'] = new sfWidgetFormTextarea();
	    
            /* Validators */
            
            $this->validatorSchema['sender']   = new sfValidatorEmail(array('required' => true));
            $this->validatorSchema['receiver']   = new sfValidatorEmail(array('required' => true));
            $this->validatorSchema['message']       = new sfValidatorString(array('required' => false));
            
            
            /* Schema */
            $this->validatorSchema['sender']->setMessage('required', 'Veuillez renseigner votre email');
            $this->validatorSchema['receiver']->setMessage('required', 'Veuillez renseigner l\'email de votre ami');
            $this->validatorSchema['message']->setMessage('required', 'Veuillez renseigner votre message');
	
            $this->validatorSchema['sender']->setMessage('invalid', 'Email invalide');
            $this->validatorSchema['receiver']->setMessage('invalid', 'Email invalide');
	    
            $this->widgetSchema->setLabels(
		array(
			'sender'    => 'Votre adresse email',
			'receiver'  => 'L\'adresse email de votre ami(e):',
                        'message'   => 'Message'
            ));
	
            $this->widgetSchema->setDefaults(
                  array('message' => "Salut, Je te conseille de jeter un coup d'oeil car ça l'air intéressant...")
            );
                    
            $this->widgetSchema->setNameFormat('sendFriend[%s]');
            $this->widgetSchema->setFormFormatterName('div');
            $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('messages');
    }
}